<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        var num = 20;
        console.log(num);

        function fun(count) {
            count += 1;
            console.log(count);
        }
        fun(num);
        console.log(num);

        var obj = {
            name: '老周'
        }
        console.log(obj.name); // 老周

        function funObj(item) { // 引用类型的赋值:把当前变量存储的值(具体数据的引用即地址)复制一份给接收的变量
            item.name = '老曾';
            console.log(item.name); // '老曾'
        }

        funObj(obj);
        console.log(obj.name); // 老曾



        // 案例
        var arr = [1, 2, 3];
        var arr2 = arr;

        console.log(arr, arr2); // [1,2,3], [1,2,3]

        function funArr(nums) {
            nums.push(4);
            console.log(nums); //  [1,2,3,4]
        }

        // 调用函数
        funArr(arr2);
        console.log(arr, arr2); //  [1,2,3,4], [1,2,3,4]


        // 给 arr2 重新赋值
        arr2 = [1, 2, 3];
        console.log(arr, arr2); // [1,2,3,4],[1,2,3]


    </script>
</head>

<body>

</body>

</html>